import {
  request,
  METHOD
} from '@/utils/request'
import axios from 'axios'

import Cookie from 'js-cookie'
const BASE_URL = process.env.VUE_APP_API_URL

/**
/*
分页查全部骑手
*/
export async function riderList (params) {
  return request(`${BASE_URL}/member/admin/storeMembers`, METHOD.GET, params)
}

// 查看 骑手
export async function riderSee (id, data) {
  return request(`${BASE_URL}/member/admin/storeMembers/${id}`, METHOD.GET, data || {})
}
export async function riderSeePer (id, data) {
  return request(`${BASE_URL}/member/admin/members/${id}`, METHOD.GET, data || {})
}
// 注销 骑手
export async function riderRomove (id) {
  return request(`${BASE_URL}/member/admin/memberBlacklist/remove/${id}`, METHOD.POST)
}
export async function countByStatus (data) {
  return request(`${BASE_URL}/order/admin/vehicleOrder/countByStatus`, METHOD.GET, data)
}

// 企业 信息表全部查询
export async function companiesAllList (params) {
  return request(`${BASE_URL}/business/admin/companies/all/list`, METHOD.GET, params)
}
export async function parentCompanyIdGet (parentCompanyId) {
  return request(`${BASE_URL}/business/admin/stores/findByParentCompanyId/${parentCompanyId}`, METHOD.GET)
}
// 查询全部门店
export async function getAllStore (data) {
  return request(`${BASE_URL}/business/admin/stores/all`, METHOD.GET, data)
}

export async function vehicleDeviceInfoAdd (data) {
  return request(`${BASE_URL}/business/admin/vehicleDeviceInfo`, METHOD.POST, data)
}
export async function vehicleShelfInfoAdd (data) {
  return request(`${BASE_URL}/business/admin/vehicleShelfInfo`, METHOD.POST, data)
}
// 企业所有人 信息表全部查询
export async function companiesPresonList (params) {
  return request(`${BASE_URL}/business/admin/companies/list/vehicleBelongId`, METHOD.GET, params)
}
// 根据企业信息查询代理上列表
export async function agentList (id) {
  return request(`${BASE_URL}/business/admin/companies/${id}/list`, METHOD.GET)
}
// 根据供应商的ID查询门店列表
export async function storeListGet (companyId) {
  return request(`${BASE_URL}/business/admin/stores/${companyId}/stores`, METHOD.GET)
}
// 骑手新增
export async function companiesAdd (data) {
  return request(`${BASE_URL}/member/admin/storeMembers`, METHOD.POST, data)
}
// 骑手修改
export async function companiesUpdate (id, data) {
  return request(`${BASE_URL}/member/admin/storeMembers/${id}`, METHOD.PUT, data)
}

// 骑手模板下载
// export async function companiesTemplate () {
//   return request(`${BASE_URL}/member/admin/import/getMemberInfosFilterExcelTemplate`, METHOD.GET, { responseType: 'blob' })
// }

export const companiesTemplate = () => {
  const queryParams = {
    Authorization: Cookie.get('Authorization')
  }
  Object.assign(queryParams)
  return axios({
    method: 'get',
    url: `${BASE_URL}/member/admin/import/getMemberInfosFilterExcelTemplate`,
    responseType: 'blob'
  })
}
export const putInStorageTemplate = () => {
  const queryParams = {
    Authorization: Cookie.get('Authorization')
  }
  Object.assign(queryParams)
  return axios({
    method: 'get',
    url: `${BASE_URL}/business/admin/putInStorageVehicleInfo/template`,
    responseType: 'blob'
  })
}
export const batchMatchingLicensePlateTemplate = () => {
  const queryParams = {
    Authorization: Cookie.get('Authorization')
  }
  Object.assign(queryParams)
  return axios({
    method: 'get',
    url: `${BASE_URL}/business/admin/putInStorageVehicleInfo/batchMatchingLicensePlateTemplate`,
    responseType: 'blob'
  })
}
// 企业导入
export async function companiesImportant (data) {
  return request(`${BASE_URL}/member/admin/import/memberInfosFilterExcel`, METHOD.POST, data)
}
export async function importVinNo (data) {
  return request(`${BASE_URL}/business/admin/vehicleShelfInfo/checkVinNoExcel/2`, METHOD.POST, data)
}

// 车辆批量分配

export async function companiesAllBusiness (data) {
  return request(`${BASE_URL}/business/admin/vehicles/distribution`, METHOD.POST, data)
}
// 批量匹配车牌
export async function batchMatchingImportant (data) {
  return request(`${BASE_URL}/business/admin/putInStorageVehicleInfo/batchMatchingLicensePlate`, METHOD.POST, data)
}
export async function channelInfoList (data) {
  return request(`${BASE_URL}/order/admin/channelInfo`, METHOD.GET, data)
}
export async function countOrderList () {
  return request(`${BASE_URL}/order/admin/channelInfo/countOrder`, METHOD.GET)
}

// 车辆列表-车辆详情-更改车牌号
export async function changePlateNo (data) {
  return request(`${BASE_URL}/business/admin/vehicles/updateLicensePlateNo`, METHOD.POST, data)
}
// 客服-车辆异常提醒-导出
export const exportException = (params) => {
  const queryParams = {
    Authorization: Cookie.get('Authorization')
  }
  Object.assign(queryParams)
  return axios({
    method: 'get',
    timeout: 60 * 1000,
    url: `${BASE_URL}/statistical/admin/vehicleException/batch/download`,
    responseType: 'blob',
    params
  })
}
// 客服-服务费扣款订单数据-导出
export const exportWithhold = (params) => {
  const queryParams = {
    Authorization: Cookie.get('Authorization')
  }
  Object.assign(queryParams)
  return axios({
    method: 'get',
    timeout: 60 * 1000,
    url: `${BASE_URL}/order/admin/serviceFeeDeduction/download`,
    responseType: 'blob',
    params
  })
}

// 关闭维修工单 维保管理 维修详情
export async function closePartsOrder (id, data) {
  return request(`${BASE_URL}/todo/admin/repairOrders/${id}/closeRepairOrder`, METHOD.POST, data)
}
// 订单退款-打款
export async function backFuckMoney (id) {
  return request(`${BASE_URL}/order/admin/vehicleOrderRefund/payment/${id}`, METHOD.GET)
}
// 骑手详情-调整冻结天数
export async function changeFrozenDays (data) {
  return request(`${BASE_URL}/order/admin/vehicleOrderFrozenLog/save`, METHOD.POST, data)
}
// 骑手详情-冻结记录列表
export async function getFrozenDaysList (data) {
  return request(`${BASE_URL}/order/admin/vehicleOrderFrozenLog/findByUserId`, METHOD.GET, data)
}
// 骑手详情-添加标签
export async function addTips (data) {
  return request(`${BASE_URL}/member/admin/memberLabel/add`, METHOD.POST, data)
}
// 骑手详情-获取已有标签、
export async function getAllTips (riderId) {
  return request(`${BASE_URL}/member/admin/memberLabel/${riderId}`, METHOD.GET)
}
// 骑手详情-删除
export async function deleteAllTips (data) {
  return request(`${BASE_URL}/member/admin/memberLabel/delete`, METHOD.POST, data)
}
// 骑手详情-标签记录
export async function getTipsLogs (data) {
  return request(`${BASE_URL}/member/admin/memberLabel/findLabelLog`, METHOD.GET, data)
}
// 骑手明细-导出
export const exportRiderDetail = (params) => {
  const queryParams = {
    Authorization: Cookie.get('Authorization')
  }
  Object.assign(queryParams)
  return axios({
    method: 'get',
    timeout: 60 * 1000,
    url: `${BASE_URL}/member/admin/members/personal/export`,
    responseType: 'blob',
    params
  })
}

// 骑手违法-跟进记录
export async function illFollowRecord (illegalId) {
  return request(`${BASE_URL}/member/admin/storeIllegal/findIllegalFollowRecord/${illegalId}`, METHOD.GET)
}
// 骑手违法-新增跟进
export async function addIllFollow (data) {
  return request(`${BASE_URL}/member/admin/storeIllegal/saveIllegalFollow`, METHOD.POST, data)
}
// 骑手违法扣款列表
export async function illRiderDebitList (params) {
  return request(`${BASE_URL}/order/admin/orderIllegal/page`, METHOD.GET, params)
}
// 骑手违法扣款详情
export async function illRiderDebitDetail (id) {
  return request(`${BASE_URL}/order/admin/orderIllegal/detail/${id}`, METHOD.GET)
}
// 审核违法扣款
export async function aduitIllRiderDebit (data) {
  return request(`${BASE_URL}/order/admin/orderIllegal/audit`, METHOD.POST, data)
}
// 查询违法状态
export async function illReload (code) {
  return request(`${BASE_URL}/member/admin/storeIllegal/history/${code}`, METHOD.GET)
}
// 骑手微信解绑
export async function wxUnbind (id) {
  return request(`${BASE_URL}/member/admin/members/wxUnbind/${id}`, METHOD.PUT)
}
// 骑手详情来电记录
export async function riderTelegramLog (data) {
  return request(`${BASE_URL}/member/admin/member/calllog/pagelist`, METHOD.GET, data)
}
// 查询注销信息
export async function riderLogoutInfo (id) {
  return request(`${BASE_URL}/member/admin/members/cancel/log?memberId=${id}`, METHOD.GET)
}
// 注销用户
export async function logoutUser (data) {
  return request(`${BASE_URL}/member/admin/members/cancel`, METHOD.POST, data)
}
// 会员等级列表
export async function riderLevelList () {
  return request(`${BASE_URL}/member/admin/base/member/level/namelist`, METHOD.GET)
}

// 1.6.6 骑手管理-骑手详情-获取单个骑手钱包余额
export async function getBalance (memberId) {
  return request(`${BASE_URL}/order/admin/memberBalance/${memberId}`, METHOD.GET)
}
// 1.6.6 骑手管理-骑手详情-租车欠款金额对应的订单列表
export async function getBalanceOrder (memberId) {
  return request(`${BASE_URL}/order/admin/memberBalance/arrearsVehicleOrder/${memberId}`, METHOD.GET)
}
// 1.6.6 骑手管理-骑手详情-骑手钱包余额明细列表
export async function getQianbao (data) {
  return request(`${BASE_URL}/order/admin/memberBalanceList`, METHOD.GET, data)
}
// 1.6.6 骑手管理-骑手详情-查看达人码
export async function masterCode (memberId) {
  return request(`${BASE_URL}/member/admin/talent/${memberId}`, METHOD.GET)
}
// 1.6.6 骑手管理-骑手详情-达人码-解绑门店
export async function unbindStore (data) {
  return request(`${BASE_URL}/member/admin/talent/unbindStore`, METHOD.POST, data)
}
// 1.6.6 骑手管理-骑手详情-达人码-解绑上级
export async function unbindMember (data) {
  return request(`${BASE_URL}/member/admin/talent/unbindMember`, METHOD.POST, data)
}
// 1.6.6 骑手管理-达人分佣记录
export async function daRenList (data) {
  return request(`${BASE_URL}/order/admin/kolCommission`, METHOD.GET, data)
}
// 1.6.6 骑手管理-达人分佣记录-统计
export async function daRenTongji (data) {
  return request(`${BASE_URL}/order/admin/kolCommission/statistics`, METHOD.GET, data)
}
// 1.6.6 骑手管理-达人分佣记录-导出明细
export const darenDownload = (params) => {
  const queryParams = {
    Authorization: Cookie.get('Authorization')
  }
  Object.assign(queryParams)
  return axios({
    method: 'get',
    timeout: 60 * 1000,
    url: `${BASE_URL}/order/admin/kolCommission/download`,
    responseType: 'blob',
    params
  })
}
// 1.6.6 骑手管理-骑手详情-达人码-门店绑定记录列表
export async function expertList (data) {
  return request(`${BASE_URL}/member/admin/talent/storeBindRecord`, METHOD.GET, data)
}

// 1.6.6 骑手管理-骑手详情-达人码-下级骑手列表
export async function nextRider (data) {
  return request(`${BASE_URL}/member/admin/talent/memberBindRecord`, METHOD.GET, data)
}
